#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 20;
#define ll long long
int n,m,L,V,t,ans;
int p[maxn],pv[maxn],nd[maxn];
struct car{
    int d,v,a,l,r;
}cr[maxn];
template <typename T> void read(T &x){
    int f = 1;
    char c = getchar();
    x = 0;
    for(;!isdigit(c);c = getchar())if(c =='-')f = -1;
    for(;isdigit(c);c = getchar())x = (x << 3) + (x << 1) + (c ^ 48);
    x *= f;
}
template <typename T> void write(T x){
    if(x < 0){
        putchar('-');
        x = -x;
    }
    if(x > 9){
        write(x / 10);
    }
    putchar(x % 10 + '0');
}
template <typename T> void writein(T x){
    write(x);
    puts("");
}
void solve(int x){
    if(cr[x].v > V){
        cr[x].l = cr[x].d - 1;
        if(cr[x].a >= 0){
            cr[x].r = L;
        }
        else{
            cr[x].r = (V * V - cr[x].v * cr[x].v) / (2 * cr[x].a) + cr[x].d;
            cr[x].r = min(L,cr[x].r);
        }
    }
    else {
        if(cr[x].a > 0){
            cr[x].l = ceil((V * V - cr[x].v * cr[x].v) / (2 * cr[x].a)) + cr[x].d;
            if(cr[x].l > L){
                cr[x].l = -1;
                cr[x].r = -1;
            }
            else cr[x].r = L;
        }
        else{
            cr[x].r = -1;
            cr[x].l = -1;
        }
    }
    return;
}
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    read(t);
    while(t--){
        ans = 0;
        read(n);
        read(m);
        read(L);
        read(V);
        for(int i = 1;i <= n;i++){
            read(cr[i].d);
            read(cr[i].v);
            read(cr[i].a);
            solve(i);
        }
        for(int i = 1;i <= m;i++){
            read(p[i]);
            pv[p[i]] = 1;
        }
        for(int i = 1;i <= L + 1;i++){
            if(pv[i])pv[i] = pv[i - 1] + 1;
            else pv[i] = pv[i - 1];
        }
        for(int i = 1;i <= n;i++){
            if(cr[i].l == -1 && cr[i].r == -1)continue;
            if(pv[cr[i].r] > pv[cr[i].l]){
                ans++;
            }
        }
        write(ans);
        printf(" ");
        writein(m - 1);
    }
    return 0;
}
